package cn.etynit.org.service.impl;

import cn.etynit.basic.util.PageList;
import cn.etynit.org.domain.SDdetail;
import cn.etynit.org.mapper.SDdetailMapper;
import cn.etynit.org.query.SDdetailQuery;
import cn.etynit.org.service.SDdetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SDdetailServiceImpl implements SDdetailService {

    @Autowired
    private SDdetailMapper sDdetailMapper;

    @Override
    public List<SDdetail> findAll() {
        return sDdetailMapper.findAll();
    }

    @Override
    public PageList<SDdetail> queryByPage(SDdetailQuery sDdetailQuery) {
        // 查询条数
        Integer totals = sDdetailMapper.queryByCount(sDdetailQuery);
        if (null == totals || 0 == totals){
            return new PageList<>(0,new ArrayList<>());
        }
        // 查询数据
        List<SDdetail> sDdetails = sDdetailMapper.queryByPage(sDdetailQuery);
        return new PageList<>(totals,sDdetails);
    }

    @Override
    public void add(SDdetail sDdetail) {
        sDdetailMapper.add(sDdetail);
    }

    @Override
    public void update(SDdetail sDdetail) {
        sDdetailMapper.update(sDdetail);
    }

    @Override
    public void delete(Long id) {
        sDdetailMapper.delete(id);
    }

    @Override
    public void batchDel(List<Long> ids) {
        sDdetailMapper.batchDel(ids);
    }
}
